<?php
require("DB.php");


$sql_order = "select * from dlz_order_product where option_status='0'";
$query_order = $db->query($sql_order);//返回影响了多少行数据
while($row_order = $query_order->fetch()){
			$sql_arrary = array();
			$sql_arrary['increment_id'] = $row_order['increment_id'];
			$child_id = $row_order['child_id'];
			$sql_arrary['product_id'] = $row_order['product_id'];
			$sql_arrary['category'] = $row_order['category'];
			$sql_arrary['status'] = $row_order['status'];
			$sql_arrary['type_id'] = $row_order['type_id'];
			$sql_arrary['created_at'] = $row_order['created_at'];
			$sql_arrary['updated_at'] = $row_order['updated_at'];
			$sql_arrary['weight'] = $row_order['weight'];
			$inch = $row_order['inch'];
			$sql_arrary['color'] = $row_order['color'];
			$sql_arrary['grade'] = $row_order['grade'];
			$sql_arrary['texture'] = $row_order['texture'];
			$sql_arrary['package'] = $row_order['package'];
			$sql_arrary['type_country'] = $row_order['type_country'];
			$sql_arrary['hairDesign'] = $row_order['hairDesign'];
			$sql_arrary['type'] = $row_order['type'];
			$sql_arrary['laceWigType'] = $row_order['laceWigType'];
			$sql_arrary['density'] = $row_order['density'];
			$sql_arrary['capSize'] = $row_order['capSize'];
			$sql_arrary['laceSize'] = $row_order['laceSize'];
			$sql_arrary['lotNum'] = $row_order['lotNum'];
			$sql_arrary['productCount'] = $row_order['productCount'];
			$sql_arrary['amount'] = $row_order['amount'];
			$sql_arrary['currencyCode'] = $row_order['currencyCode'];
			$orderit_itemid = $row_order['orderit_itemid'];

			$inc_arr = explode(' ',$inch);
			$countnum = count($inc_arr);
			if ("$countnum" > "1") {
				echo "大于1 ：$inch  -";

			for($index=0;$index<$countnum;$index++) 
				{ 
					$sql_arrary['inch'] = $inc_arr[$index];//尺寸
					$sql_arrary['orderit_itemid'] = $orderit_itemid.'-'.$index;//索引
					$sql_arrary['child_id'] = $child_id.'-'.$index;//尺寸
					$result = Getinsert($arrData=$sql_arrary,$table='dlz_post_orderinfo',$db,$sync_data="0");
					//如果分解打包尺寸的订单成功，则记录状态
					if("$result" == '0'){
    					$syncstatus_sql = "update dlz_order_product set option_status='1' where child_id='$child_id'";
    					$db->exec($syncstatus_sql);
					}

				}
			}else{
				echo "小于1 ：$inch";
					$sql_arrary['inch'] = $inch;//尺寸
					$sql_arrary['orderit_itemid'] = $orderit_itemid;//索引
					$sql_arrary['child_id'] = $child_id;//尺寸
					$result = Getinsert($arrData=$sql_arrary,$table='dlz_post_orderinfo',$db,$sync_data="0");
					//如果分解打包尺寸的订单成功，则记录状态
					if("$result" == '0'){
    					$syncstatus_sql = "update dlz_order_product set option_status='1' where child_id='$child_id'";
    					$db->exec($syncstatus_sql);
					}
					
			}
}
$db = null;


//include("Postapi.php");
